<%--
  Created by IntelliJ IDEA.
  User: 王宇航
  Date: 2023/4/2
  Time: 16:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>图书管理系统首页</title>
    <script>
        function del(){
            return confirm("书否删除？");
        }
    </script>
    <c:if test="${sessionScope.user.role ne 1}">
        <c:set var="error" value="你不是管理员无法访问！" scope="session"/>
        <c:redirect url="/index.jsp"/>
    </c:if>
</head>
<body style="text-align: center">
<h1 style="color: aqua">图书管理系统首页</h1>
<p style="color: blue">当前登录的用户为:${sessionScope.user.username}</p>
<a href="/book/admin/addBook.jsp">添加图书</a>
<table border="1" style="margin: auto;text-align: center">
    <tr>
        <th>ID</th>
        <th>主题</th>
        <th>作者</th>
        <th>发布时间</th>
        <th>封面</th>
        <th colspan="3">操作</th>
    </tr>
    <c:forEach var="book" items="${sessionScope.books}">
        <tr>
            <td>${book.id}</td>
            <td>${book.title}</td>
            <td>${book.author}</td>
            <td>${book.publicationTime}</td>
            <td><img width="130px" height="200px" src="/cover/${book.cover}"></td>
            <td><a href="/book/editerStep1/${book.id}">修改</a></td>
            <td><a href="/book/removeBook/${book.id}" onclick="return del()">删除</a></td>
            <td><a href="/book/bookDetail/${book.id}">详情</a></td>
        </tr>
        </c:forEach>
    
</table>
<a href="/user/signOut">退出登录</a>
<p style="color: green">${sessionScope.message}</p>
</body>
</html>
